#!/bin/bash
set -e
if [ -z $CLOONIX_CONFIG ]; then
  CLOONIX_CONFIG=/usr/local/bin/cloonix/cloonix_config
fi

if [ ! -f $CLOONIX_CONFIG ]; then
  echo "ERROR: $CLOONIX_CONFIG not found"
  exit 1
fi
CLOONIX_TREE=$(cat $CLOONIX_CONFIG |grep  CLOONIX_TREE | awk -F = '{print $2}')

if [ ! -d ${CLOONIX_TREE} ]; then
  echo "ERROR: ${CLOONIX_TREE} not found"
  exit 1
fi

${CLOONIX_TREE}/client/ctrl/cloonix_ctrl $CLOONIX_CONFIG "$@"

